
/*
*   网络相关接口定义
*  
*/
export type NetData = (string | ArrayBufferLike | Blob | ArrayBufferView);

// Socket接口
export interface ISocket {
    onConnected: (event) => void;           // 连接回调
    onMessage: (msg: NetData) => void;      // 消息回调
    onError: (event) => void;               // 错误回调
    onClosed: (event) => void;              // 关闭回调

    connect(options: any);                  // 连接接口
    send(buffer: NetData);                  // 数据发送接口
    close(code?: number, reason?: string);  // 关闭接口
}

// Socket 链接参数
export interface ISocketOptions {
    url?: string;
    ip?: string;
    port?: string;
    protocol?: string;
    binaryType?: BinaryType;
}